<template>  
  <view class="page-container">   
    <image class="bg-image" src="/static/image.jpg" mode="aspectFill"></image>
    
    <view class="content">
      <view class="nav-bar">
        <view class="back-btn" @click="goBack">
          <image src="/static/return.png" mode="aspectFit" class="back-icon"/>
        </view>
        <text class="nav-title">找回密码</text>
      </view>

      <form @submit.prevent="onSubmit">  
        <view class="input-group">  
          <text class="label">手机号</text>  
          <input 
            class="input"
            v-model="phone" 
            placeholder="请输入手机号" 
            placeholder-class="placeholder"
            type="number" 
          />  
        </view>  

        <view class="input-group">  
          <text class="label">验证码</text>  
          <view class="code-group">  
            <input 
              class="input code-input"
              v-model="verificationCode" 
              placeholder="请输入验证码"
              placeholder-class="placeholder" 
            />  
            <button 
              class="code-button" 
              @click.prevent="sendVerificationCode" 
              :disabled="isSending"
              :class="{ 'button-disabled': isSending }"
            >
              {{ isSending ? '发送中...' : '发送验证码' }}
            </button>  
          </view>  
        </view>  

        <view class="input-group">  
          <text class="label">新密码</text>  
          <view class="password-container">
           <input
             v-model="password"  
             class="input"  
             placeholder="请输入密码"  
             placeholder-class="placeholder"
             :type="showPassword ? 'text' : 'password'"  
           />  
           <image
             class="password-toggle"
             :src="showPassword ? '/static/btn_hide_login.png' : '/static/btn_visible_login.png'"
             @click="togglePassword"
             mode="aspectFit"
           />
          </view>
        </view>  

        <view class="input-group">  
          <text class="label">确认密码</text>  
          <view class="password-container">
           <input
             v-model="password"  
             class="input"  
             placeholder="请输入密码"  
             placeholder-class="placeholder"
             :type="showPassword ? 'text' : 'password'"  
           />  
           <image
             class="password-toggle"
             :src="showPassword ? '/static/btn_hide_login.png' : '/static/btn_visible_login.png'"
             @click="togglePassword"
             mode="aspectFit"
           />
          </view>
        </view>  

        <button type="submit" class="submit-button">确认重置</button>  
      </form>  
    </view>
  </view>  
</template>  

<script>  
export default {  
  data() {  
    return {  
      phone: '',  
      verificationCode: '',  
      password: '',  
      confirmPassword: '',  
      isSending: false,
      showPassword: false,
      showConfirmPassword: false
    };  
  },  
  methods: {  
    togglePassword() {
      this.showPassword = !this.showPassword;
    },
    toggleConfirmPassword() {
      this.showConfirmPassword = !this.showConfirmPassword;
    },
    sendVerificationCode() {  
      if (!this.phone) {  
        uni.showToast({ title: '请输入手机号', icon: 'none' });  
        return;  
      }  
      this.isSending = true;  
      setTimeout(() => {  
        uni.showToast({ title: '验证码已发送', icon: 'success' });  
        this.isSending = false;  
      }, 2000);
    },  
    onSubmit() {  
      if (this.password !== this.confirmPassword) {  
        uni.showToast({ title: '两次密码不一致', icon: 'none' });  
        return;  
      }  
      uni.showToast({ title: '密码重置成功', icon: 'success' });
      setTimeout(() => {
        uni.navigateBack();
      }, 1500);
    },  
    goBack() {
      uni.navigateBack();
    },
  },  
};  
</script>  

<style scoped>
.page-container {
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.bg-image {
  position: absolute;
  width: 100%;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: 1;
}

.content {
  position: relative;
  z-index: 2;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.input-group {  
  margin-bottom: 20px;  
}  

.label {
  font-size: 14px;
  color: #333;
  margin-bottom: 8px;
  display: block;
  font-weight: 500;
}

.input {
  width: 92%;
  height: 45px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 0 15px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(5px);
}

.code-group {  
  display: flex;  
  align-items: center;
  gap: 10px;
}  

.code-input {
  flex: 1;
}

.code-button {  
  width: 110px;
  height: 45px;
  background: rgba(107, 75, 138, 0.8);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  backdrop-filter: blur(5px);
}

.button-disabled {
  background: rgba(204, 204, 204, 0.8);
}

.password-container {
  position: relative;
}

.password-toggle {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.submit-button {  
  background: rgba(107, 75, 138, 0.8);
  color: white;
  height: 45px;
  border: none;
  border-radius: 25px;
  width: 100%;
  font-size: 16px;
  font-weight: 500;
  margin-top: 40px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  backdrop-filter: blur(5px);
}  

.submit-button:active {
  transform: scale(0.98);
}

.nav-bar {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  margin-bottom: 20px;
}

.back-btn {
  padding: 30px;
  margin-left: -50px;
}

.back-icon {
  width: 30px;
  height: 30px;
}

.nav-title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  margin-right: 40px;
  color: #333;
}
</style>